package testgrid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import com.lex.activitytext.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/7/4.
 */
public class GridViewActivity extends Activity {
    private GridView gridView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_grid_view);
        findView();
        initView();
    }

    private void findView() {
        gridView = (GridView) findViewById(R.id.grid_view);
    }

    private void initView() {
        List<Map<String, Object>> data = new ArrayList<>();
        for (int i = 0; i < 100; i++){
            Map<String, Object> map = new HashMap<>();
            map.put("name", "有趣");
            map.put("image", R.mipmap.ic_launcher);
            data.add(map);
        }
        gridView.setAdapter(new SimpleAdapter(this,data,
                R.layout.item_grid_view_item,new String[]{"name","image"},
                new int[]{R.id.text111,R.id.image}));
    }
}
